package com.james.controller;

import com.james.entity.User;
import com.james.repository.UserRepository;
import com.james.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;


@Controller
@RequestMapping("/user")
public class UserHandler {

    @Autowired
    private UserService userService;

    @RequestMapping("/findAll")
    public ModelAndView index(){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("index");
        modelAndView.addObject("list",userService.findAll());
        //List<User> res = userService.findAll();
        return modelAndView;
    }
}
